#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
	int n;
	while (cin>>n)
	{
		vector<int>v(n);
		for (int i = 0; i < n; i++)
			cin >> v[i];
		int flag = 0, count = 0;
		while (!flag)
		{
			int pre = v[n-1];
			for (int i = 0; i < n;i++)
			{
				int temp = v[i];
				v[i] = (v[i] + pre) / 2;
				pre = temp;
			}
			int num = 0;
			for (int i = 0; i < n;i++)
			{
				if (v[i] % 2 != 0)
				{
					v[i]++; count++;
				}
				if (v[i] == v[0])num++;
			}
			if (num == n)flag = 1;
		}
		cout << count << endl;
	}
	return 0;
}